package com.huanying.framework.parameter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huanying.framework.BaseDao;

@Service
public class ParameterServiceImpl implements ParameterService {
	@Autowired
	private BaseDao dao;
	
	@Override
	public void intParamObject() throws Exception {
		if(Parameter.getPara_object() != null){
			String hql = "from Parameter where status=1";
			List param_list = dao.exculeHqlByParams(hql, null);
			hql = "select distinct p.para_type_code from Parameter p where p.status=1";
			List type_list = dao.exculeHqlByParams(hql,null);
			String type_str;
			Parameter param_obj;
			Map paramObject = new HashMap();
			for(int i=0;i<type_list.size();i++){
				type_str = (String)type_list.get(i);
				for(int j=0;j<param_list.size();j++){
					Map sub_param_map = new HashMap();
					param_obj = (Parameter)param_list.get(j);
					if(type_str.equals(param_obj.getPara_type_code())){
						sub_param_map.put(param_obj.getPara_value(),param_obj.getPara_name());
					}
					paramObject.put(type_str, sub_param_map);
				}
			}
			Parameter.setPara_object(paramObject);
		}
	}
	
	@Override
	public Map<String,String> findParamsByType(String para_type_code) throws Exception {
		return null;
	}


	@Override
	public String getParamValueByName(String para_name) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getParamNameByValue(String para_value) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
